package com.sy.nio.c1;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @Author yumax
 * @Date 2024 01 05 18 58
 **/
public class WriteClient {
    public static void main(String[] args) throws IOException {
        final SocketChannel sc = SocketChannel.open();
        sc.connect(new InetSocketAddress("localhost", 8989));

        int count = 0;
        while (true) {
            final ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
            final int len = sc.read(buffer);
            count += len;
            System.out.println(count);
            buffer.clear();
        }
    }
}
